﻿using System.Drawing;

namespace InterLock.Equipmet
{
    /// <summary>
    /// 轨道区段
    /// </summary>
    public class Track : Equipment
    {
        private Pen bluePen = new Pen(Color.Blue, 2);
        private Pen whitePen = new Pen(Color.White, 2);
        private Pen grayPen = new Pen(Color.Gray, 2);

        public override Rectangle Region
        {
            get
            {
                return new Rectangle(X1, Y1 - 2, X2 - X1, 6);
            }
        }

        /// <summary>
        /// 绘制轨道区段
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            if (!SJ)
            {
                g.DrawLine(bluePen, X1, Y1, X2, Y2);
            }
            if (SJ)
            {
                g.DrawLine(whitePen, X1, Y1, X2, Y2);
            }
            if (ZYJ)
            {
                Pen redPen = new Pen(Color.Red, 2);
                g.DrawLine(redPen, X1, Y1, X2, Y2);
            }
            g.DrawLine(grayPen, X1, Y1 - 5, X1, Y1 + 5);
            g.DrawLine(grayPen, X2, Y2 - 5, X2, Y2 + 5);

            //绘制名称
            g.DrawString(Name, new Font("宋体", 9, FontStyle.Bold), Brushes.White, X1 + (X2 - X1) / 2 - 15, Y1 - 15);
        }
    }
}
